//
//  RNOLMyBankCardViewController.m
//  RongNiuOnline
//
//  Created by apple on 2018/4/25.
//  Copyright © 2018年 rongniu. All rights reserved.
//

#import "RNOLMyBankCardViewController.h"
#import "RNOLBankCardView.h"
#import "RNOLAuthPayViewController.h"

@interface RNOLMyBankCardViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView *tableView;

@end

@implementation RNOLMyBankCardViewController
- (UITableView *)tableView{
    if(!_tableView){
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KWIDTH , KHIGHT) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = kBgColor;
        adjustsScrollViewInsets_NO(_tableView, self);
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 50;
        UIView *cardBg = [RNOLUnitTool createViewWithBackgroundColor:KWhiteColor];
        cardBg.frame = CGRectMake(0, 0, KWIDTH , 180);
        RNOLBankCardView *cardView = [RNOLBankCardView FromXIB];
        cardView.frame = CGRectMake(0, 10, 330 , 160);
        cardView.centerX = cardBg.centerX;
        [cardBg addSubview: cardView];
        _tableView.tableHeaderView = cardBg;
        _tableView.tableFooterView = [UIView new];
        [self.view addSubview: _tableView];
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kBgColor;
    [self setupNavBarTitleViewWithText:@"我的银行卡"];
    [self tableView];
    [RNOLLoginTool setNavgationBarNeedAnimation:YES];

}

#pragma mark -  UITableViewDelegate && UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.imageView.image = [UIImage imageNamed:@"rnol_commom_add"];
    cell.textLabel.text = @"充值添加银行卡";
    cell.textLabel.textColor = kTextColor;
    cell.textLabel.font = KFontSize(12);
    return cell;
}

- (void)viewDidLayoutSubviews
{
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
    }
    
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
    }
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self pushPageWithClass:[RNOLAuthPayViewController class]];
    
}

@end
